package file;

import java.io.File;
import java.io.FileFilter;

public class Test {
    public static void main(String[] args) {
        File dir = new File(".");
        if(dir.isDirectory()){
            FileFilter filter = new FileFilter() {
                @Override
                public boolean accept(File file) {
                    String fileName =file.getName();
                    System.out.println("正在过滤"+fileName);
                    return fileName.contains("a");
                }
            };
            File[] subs =dir.listFiles(filter);
            System.out.println("满足过滤器要求的子项共"+subs.length+"个");
            for (int i = 0; i <subs.length ; i++) {
                System.out.println(subs[i].getName());

            }

        }

    }
}
